/*
 * Copyright (c) 2014-2024 Stream.io Inc. All rights reserved.
 *
 * Licensed under the Stream License;
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    https://github.com/GetStream/stream-video-android/blob/main/LICENSE
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.gitee.wsl.compose.ui.theme.style

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp


/**
 * Represents an icon style. Consists of color and padding.
 *
 * @param color the color applied as tint to the icon.
 * @param padding the padding applied to the icon.
 */
 data class IconStyle(
    val color: Color,
    val padding: PaddingValues = PaddingValues(0.dp),
) : UiStyle

/**
 * Contains state styles for the icon.
 */
 data class UiIconStyle(
    override val default: IconStyle,
    override val pressed: IconStyle?=null,
    override val disabled: IconStyle?=null,
) : UiStateStyle<IconStyle>

/**
 * Provides default icon style.
 */
 open class IconStyleProvider {

    /**
     * Composable that provides default icon style.
     *
     * @param padding the padding values of the icon.
     * @param default normal color of the icon.
     * @param pressed color of the icon when pressed
     * @param disabled color of the icon when disabled
     *
     * @see [UiIconStyle]
     */
    @Composable
     fun defaultIconStyle(
        padding: PaddingValues = PaddingValues(0.dp),
        default: Color = MaterialTheme.colorScheme.primary,
        pressed: Color = MaterialTheme.colorScheme.primary,
        disabled: Color = MaterialTheme.colorScheme.tertiary,
    ): UiIconStyle = UiIconStyle(
        default = IconStyle(default, padding),
        pressed = IconStyle(pressed, padding),
        disabled = IconStyle(disabled, padding),
    )

    @Composable
     fun customColorIconStyle(color: Color): UiIconStyle = defaultIconStyle(
        default = color,
        pressed = color,
        disabled = color.copy(alpha = 0.16f),
    )
}

/**
 * Object accessor for a default [IconStyleProvider]
 */
 object IconStyles : IconStyleProvider()
